home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / TIPS / SPLASH.PAS < prev    next >
Pascal/Delphi Source File  |  1991-10-09  |  2KB  |  65 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Tips & Techniques Demo Program               }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program Splash;
  10.  
  11. {$R Splash}
  12.  
  13. uses WinProcs, WinTypes, WObjects;
  14.  
  15. type
  16.   TApp = object(TApplication)
  17.     constructor Init(AName: PChar);
  18.     procedure InitMainWindow; virtual;
  19.   end;
  20.  
  21. var
  22.   SplashRect: TRect;
  23.  
  24. { Before calling the parent constructor, create a 'Display'
  25.   DC and BitBlt the desired region }
  26. constructor TApp.Init(AName: PChar);
  27. var
  28.   DC, MemDC: HDC;
  29.   OldBitMap, BitMap: HBitMap;
  30.   BM: TBitMap;
  31. begin
  32.   DC := CreateDC('Display', Nil, Nil, Nil);
  33.   BitMap := LoadBitMap(HInstance, 'Splash');
  34.   MemDC := CreateCompatibleDC(DC);
  35.   OldBitMap := SelectObject(MemDC, BitMap);
  36.   GetObject(BitMap, SizeOf(BM), @BM);
  37.   with SplashRect do
  38.   begin
  39.     Left := 200;
  40.     Top := 150;
  41.     Right := Left + BM.bmWidth;
  42.     Bottom := Top + BM.bmHeight;
  43.     BitBlt(DC, Left, Top, BM.bmWidth, BM.bmHeight, MemDC, 0, 0, SRCCopy);
  44.   end;
  45.   DeleteObject(SelectObject(MemDC, OldBitMap));
  46.   DeleteDC(MemDC);
  47.   DeleteDC(DC);
  48.   TApplication.Init(AName);
  49. end;
  50.  
  51. procedure TApp.InitMainWindow;
  52. begin
  53.   MainWindow := New(PWindow, Init(Nil, 'Splash Test'));
  54. end;
  55.  
  56. var
  57.   App: TApp;
  58. begin
  59.   App.Init('Splash');
  60.   { invalidate the Splashed region to cause a paint }
  61.   InvalidateRect(0, @SplashRect, True);
  62.   App.Run;
  63.   App.Done;
  64. end.
  65.